﻿using Microsoft.Services.TestTools.UITesting.Html;
using Microsoft.VisualStudio.TestTools.UITesting;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Xml;
using System.Configuration;
using TestCalculator;

namespace CodedUITest
{

    [CodedUITest]
    public class TestSuite
    {
        private TestContext testContextInstance;
        private string applicationPath = ConfigurationManager.AppSettings["ApplicationPath"];

        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        [DeploymentItem("Parameters.xml"), DataSource("Microsoft.VisualStudio.TestTools.DataSource.XML", "|DataDirectory|\\Parameters.xml", "Calculator", DataAccessMethod.Sequential), TestMethod]
        public void TestCalculator()
        {
            string firstNumber = TestContext.DataRow["FirstNumber"].ToString();
            string secondNumber = TestContext.DataRow["SecondNumber"].ToString();
            string result = TestContext.DataRow["Result"].ToString();

            Calculator Calculator = Page.LaunchWindow<Calculator>(applicationPath);
            Calculator.FirstNumber = firstNumber;
            Calculator.SecondNumber = secondNumber;
            Calculator.Result = result;
            
            Calculator.Multiply();
            Calculator.VerifyResult();

        }

    }
}


